import QtQuick 1.1
import com.nokia.meego 1.0
import "DucankoStyle.js" as DucankoStyle

//editDatabasePage
Page {
    id: editDatabasePage

    //background image
    Image {
        id: background
        anchors.fill: parent
        source: "qrc:/images/pozadina1.png"
        fillMode: "Stretch"
    }

    TabGroup {
         id: tab
         anchors {
             top: sectionTop.bottom
             left: parent.left
             right: parent.right
             bottom: parent.bottom
         }

         currentTab: tabGroups

         EditGroupsPage {
             id: tabGroups
             anchors.centerIn: parent
         }
         EditItemsPage {
             id: tabItems
             anchors.centerIn: parent
         }
     }

    //sectionTop
    Item {
        id: sectionTop

        anchors {
            horizontalCenter: parent.horizontalCenter

            top: parent.top
            left: parent.left

            //margins: 10
        }

        height: labelSection.height + btnRow.height
        width: parent.width

        Image{
            id: bgTop
            anchors.fill: parent
            source: "qrc:/images/diopozadine-01gore.png"
            fillMode: "Stretch"
        }

        Item {
            id: labelSection
            height: label.height*3

            anchors {
                top: parent.top
                horizontalCenter: parent.horizontalCenter
                left: parent.left
            }

            Label {
                id: label
                anchors.centerIn: parent
                text: qsTr("Edit database!")
                font.family: DucankoStyle.FONT_FAMILY
                font.pixelSize: DucankoStyle.FONT_PAGE_TITLE_SIZE
            }
        }


        ButtonRow{
            id: btnRow
            width: parent.width


            //property int itemWidth: Math.round(width/2)

            anchors {
                top: labelSection.bottom
                horizontalCenter: parent.horizontalCenter
                left: parent.left
            }

            Button{
                text: qsTr("Groups")
                anchors.left: parent.left
                anchors.right: parent.horizontalCenter
                //width: btnRow.itemWidth
                onClicked: {
                    tab.currentTab = tabGroups
                }
            }
            Button{
                text: qsTr("Items")
                anchors.left: parent.horizontalCenter
                anchors.right: parent.right
                //width: btnRow.itemWidth
                onClicked: {
                    qmlHandler.refreshItems(-1,-1)
                    tabItems.groupIndex=0 //dodal
                    tabItems.groupButtonText=qsTr("All groups") //dodal
                    tab.currentTab = tabItems
                    console.log(btnRow.itemWidth)
                }
            }
        }
    }
}




